package com.ruibang.glass.material.service.impl.cl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruibang.glass.material.domain.req.ycl.ManageLocationReq;
import com.ruibang.glass.material.entity.cl.MaterialCLLocationManagement;
import com.ruibang.glass.material.mapper.cl.GMaterialCLLocationManagementMapper;
import com.ruibang.glass.material.service.cl.GMaterialCLLocationManagementService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 原材料库位管理表 服务实现类
 * </p>
 *
 * @author mameng
 * @since 2024-04-01
 */
@Service
public class GMaterialCLLocationManagementServiceImpl extends ServiceImpl<GMaterialCLLocationManagementMapper, MaterialCLLocationManagement> implements GMaterialCLLocationManagementService {

    @Override
    public IPage<MaterialCLLocationManagement> getPage(ManageLocationReq manageLocationReq) {
        LambdaQueryWrapper<MaterialCLLocationManagement> queryWrapper = Wrappers.<MaterialCLLocationManagement>lambdaQuery();
        if (StringUtils.isNotBlank(manageLocationReq.getLocationName())) {
            queryWrapper.like(MaterialCLLocationManagement::getLocationName, manageLocationReq.getLocationName());
        }
        if (StringUtils.isNotBlank(manageLocationReq.getLocationName())) {
            queryWrapper.like(MaterialCLLocationManagement::getLocationName, manageLocationReq.getLocationName());
        }
        if (StringUtils.isNotBlank(manageLocationReq.getStatus())) {
            queryWrapper.like(MaterialCLLocationManagement::getStatus, manageLocationReq.getStatus());
        }
        Page<MaterialCLLocationManagement> materialWarehouseInfoPage = baseMapper.selectPage(new Page<>(manageLocationReq.getPageNo(), manageLocationReq.getPageSize()),
                queryWrapper.orderByDesc(MaterialCLLocationManagement::getCreateTime)
        );
        return materialWarehouseInfoPage;
    }
}
